import router from './router'
import Cookie from 'js-cookie'

const whiteList = ['/login', '/']
router.beforeEach((to, from, next) => {
  to.query.backpage = from.path
  if (Cookie.get('token')) {
    next()
  } else {
    whiteList.includes(to.path) ? next() : next('/login')
  }
})
